<?php

/**
 * Teacher form.
 *
 * @package    elearning
 * @subpackage form
 * @author     Your name here
 */
class TeacherForm extends BaseTeacherForm
{
  public function configure()
  {
  	unset( $this['teacher_last_visit'], $this['created_at'], $this['updated_at'] );
	$this->widgetSchema['teacher_avatar_img'] = new sfWidgetFormInputFileEditable(array(
	   'label'     => 'Teacher Avatar',
	   'file_src'  => '/uploads/assets/teacher/'.$this->getPicPath().'/thumb_'.$this->getObject()->getTeacherAvatarImg(),
	   'is_image'  => true,
	   'edit_mode' => !$this->isNew(),
	   'template'  => '<div><p>%file%</p><p>%input%</p><p>%delete% %delete_label%</p></div>',
	));
	
	$this->validatorSchema['teacher_avatar_img'] = new sfValidatorFile(array(
	   'required'   => !((bool)($this->getObject()->getTeacherAvatarImg())),
	   'mime_types' => 'web_images',
	   'path' => sfConfig::get('sf_upload_dir').'/assets/teacher/'.$this->getPicPath(),
	   'validated_file_class' => 'sfResizedFile',
	   'max_size'   => 41943040,
	));
  }
  
  protected function getPicPath()
  {
	return utilities::getSpreadPathByDate($this->getObject()->getCreatedAt());
  }    	 

}
